export function download(file: Blob | string, filename: string) {
  const a = document.createElement('a')
  const isBlob = file instanceof Blob
  const url = isBlob ? window.URL.createObjectURL(file) : file
  a.href = url
  a.download = filename
  document.body.appendChild(a)
  a.click()
  setTimeout(() => {
    document.body.removeChild(a)
    window.URL.revokeObjectURL(url)
  }, 0)
}

export function toHump(name: string) {
  return name.replace(/-(\w)/g, function (_, letter: string) {
    return letter.toUpperCase()
  })
}

export function toLine(name: string) {
  return name.replace(/([A-Z])/g, '-$1').toLowerCase()
}
